﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using GIMS.Def.Arguments;
using GIMS.Def.Flags;
using GIMS.Def.Settings;

namespace GIMS.Def.Operators
{
    class LabelOperator : Operator
    {

        #region Setting definition
        // define the settings from wich the operator is dependent
        // there is alredy an example-definition (replace it with the right ones)

        private FillSetting fillSetting;
        private BackgroundSetting backgroundSetting;
        private SizeSetting sizeSetting;
        private PointsizeSetting pointsizeSetting;

        #endregion

        public LabelOperator()
        {
            #region Setting instantiation
            // instantiate the Settings wich are defined in the setting-definition-region

            fillSetting = new FillSetting();
            fillSetting.Description = "The text is filled with this color";
            backgroundSetting=new BackgroundSetting();
            backgroundSetting.Description = "Background color of the created image";
            sizeSetting=new SizeSetting();
            sizeSetting.Description = "Size of the created image";
            pointsizeSetting=new PointsizeSetting();
            pointsizeSetting.Description = "Text pointsize";

            #endregion

            #region value-assignment to superclass attributes
            //assign the right values to this superclass-attributes

            name = "Label";
            description = "Creates an image wich contains the specified text";
            instruction = "label:";
            iconPath = @"Images\label.png";
            argument = new LiteralArgument();
            possiblePrograms = Program.convert;
            position = Position.First;
            settings = new List<Setting> { fillSetting, backgroundSetting, sizeSetting, pointsizeSetting };

            #endregion

            #region Argument-event registration
            //register to the events of the operator and setting arguments

            argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);
            fillSetting.Argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);
            backgroundSetting.Argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);
            sizeSetting.Argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);
            pointsizeSetting.Argument.PropertyChanged += new PropertyChangedEventHandler(OnArgumentChanged);

            #endregion

            #region Setting-event registration
            //register to the events of the settings

            fillSetting.PropertyChanged += new PropertyChangedEventHandler(OnSettingChanged);
            backgroundSetting.PropertyChanged += new PropertyChangedEventHandler(OnSettingChanged);
            sizeSetting.PropertyChanged += new PropertyChangedEventHandler(OnSettingChanged);
            pointsizeSetting.PropertyChanged += new PropertyChangedEventHandler(OnSettingChanged);

            #endregion
        }

        protected override string CreateOperatorScript()
        {
            return string.Concat(instruction, argument.CreateScriptPart());
        }
    }
}
